<?php
/**
 *@author Connor <caokang@foxmail.com>
 *@todo
 *@link www.zeevin.com
 */
?>

<div class="title">
      <h3>定义资料</h3>
      <ul>
            <li><a href="?r=home/profile" title="个人介绍">个人介绍</a></li>
            <li class="current"><a href="?r=home/intro" title="定义资料">定义资料</a></li>
      </ul>
</div>
<div class="main_content">
      <div class="definition_infor">
            <div class="definition_addinfor"> <strong>添加条目：</strong>
                  <input type="text" name="add_entry" maxlength="5"/>
                  <strong>条目下内容：</strong>
                  <input type="text" name="add_entry_con" maxlength="11"/>
                  <span class="add_but">添加</span> </div>
                  <p>温馨提示：点击可修改条目及内容。</p>
                  <div class="definition_infor_list">
                        <ul><?php if($intro->zodiac!=$drop_split):?> 
                              <li>
                                    <ul>  <?php 
                                          if($intro->isNewRecord)$tmp=array('生肖：','');else $tmp=mb_split($split, $intro->zodiac);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='zodiac'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->constellation!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('星座：','');else $tmp=mb_split($split, $intro->constellation);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='constellation'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fav_colours!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('籍贯：','');else $tmp=mb_split($split, $intro->fav_colours);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_colours'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->nationality!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('民族：','');else $tmp=mb_split($split, $intro->nationality);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='nationality'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->blood_type!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('血型：','');else $tmp=mb_split($split, $intro->blood_type);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='blood_type'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->faith!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('信仰：','');else $tmp=mb_split($split, $intro->faith);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='faith'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->black_1!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_1);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_1"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->black_2!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_2);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_2"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->weight!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('体重：','');else $tmp=mb_split($split, $intro->weight);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='weight'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->body_size!=$drop_split):?> 
                              <li>
                                    <ul>
                                          <?php 
                                          if($intro->isNewRecord)$tmp=array('体型：','');else $tmp=mb_split($split, $intro->body_size);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='body_size'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->black_3!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_3);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_3"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->black_4!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_4);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_4"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              
                              <?php if($intro->graduate_school!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('毕业学校：','');else $tmp=mb_split($split, $intro->graduate_school);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='graduate_school'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->corp!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('公司：','');else $tmp=mb_split($split, $intro->corp);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='corp'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->career!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('从事行业：','');else $tmp=mb_split($split, $intro->career);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='career'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->incomes!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('收入情况：','');else $tmp=mb_split($split, $intro->incomes);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='incomes'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                             <?php if($intro->black_5!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_5);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_5"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->black_6!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_6);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_6"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php if($intro->habits!=$drop_split):?> 
                               <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('作息习惯：','');else $tmp=mb_split($split, $intro->habits);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='habits'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->exercising!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('锻炼习惯：','');else $tmp=mb_split($split, $intro->exercising);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='exercising'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->smoke!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('是否吸烟：','');else $tmp=mb_split($split, $intro->smoke);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='smoke'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->drink!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('是否饮酒：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='drink'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->personality!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('个性特点：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='personality'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->goodat!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('擅长的技能：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='goodat'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                        <?php endif;?>
                             <?php if($intro->black_7!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_7);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_7"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                             <?php if($intro->black_8!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('','');else $tmp=mb_split($split, $intro->black_8);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id="black_8"><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                             <?php if($intro->fav_food!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的食物：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_food'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fav_sports!=$drop_split):?> 
                               <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的运动：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_sports'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fac_moves!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的电影：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fac_moves'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fav_musics!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的音乐：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_musics'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fav_book!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的书籍：','');else $tmp=mb_split($split, $intro->drink);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_book'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->fav_product!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('喜欢的产品：','');else $tmp=mb_split($split, $intro->fav_product);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='fav_product'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li><?php endif;?>
                              <?php if($intro->hobby!=$drop_split):?> 
                              <li>
                                    <ul><?php 
                                          if($intro->isNewRecord)$tmp=array('业余爱好：','');else $tmp=mb_split($split, $intro->hobby);
                                          ?>
                                          <li class="delete">删除</li>
                                          <li class="definition_addinfor_con profile" id='hobby'><?php echo CHtml::encode($tmp[0]);?></li>
                                          <li class="definition_addinfor_text"><?php echo CHtml::encode($tmp[1]);?></li>
                                    </ul>
                              </li>
                              <?php endif;?>
                              <?php 
                              if(is_array($hook)):
                                    foreach(array_reverse($hook,true) as $v):
                                          ?>
                                    <li>
                                          <ul>
                                                <li class="delete">删除</li>
                                                <li class="definition_addinfor_con" id='fav_colours'><?php echo CHtml::encode($v['subject']);?></li>
                                                <li class="definition_addinfor_text"><?php echo CHtml::encode($v['content']);?></li>
                                          </ul>
                                    </li>
                                    <?php 
                                    endforeach;
                                    endif;?>


                              </ul>
                        </div>
                        <div class="guide_first"><span class="ctrl_s">保存</span>
                  </div>
            </div>

            <script type="text/javascript">
            $(document).ready(function(){

                  $('.ctrl_s').live('click',function(){
                        var hook ={} 
                        var profile = {};
                        $('.definition_addinfor_text').each(function(){
                              $drop=0;
                              if($(this).parent().attr('drop')==1)$drop = 1;

                              $p = $.trim($(this).prev().html());
                              $v = $.trim($(this).html());
                              // if($v){
                                    var obj = $(this).prev();
                                    var id = obj.attr('id');
                                    if(obj.hasClass('profile')){
                                          if($drop)profile[id]='<?php echo $drop_split;?>';
                                          else profile[id]=obj.html()+'<?php echo $split;?>'+$v;
                                    }
                                    else{
                                          if($drop)profile[obj.html()]='<?php echo $drop_split;?>';
                                          else hook[obj.html()]=$v;
                                    }
                                          
                              // }

                        });
                        $.post('?r=home/intro',{'Profile':profile,'Hook':hook},function(data){
                              var msg='定义资料保存失败';
                              if(data){msg='定义资料保存成功';}else{msg='定义资料保存失败';}

                              $('#topmsg').html(msg)
                              $('#showmsg').show();
                              showDialog();
                              setTimeout(function(){$('#showmsg').hide();},1000);
                        })
                  });

})

</script>